import { getAbout } from '../api'

export default {
  namespaced: true,
  state: {
    loading: true,
    data: ''
  },
  mutations: {
    setLoading (state, payload) {
      state.loading = payload
    },
    setData (state, payload) {
      state.data = payload
    }
  },
  actions: {
    async fetchAbout (ctx) {
      ctx.commit('setLoading', false)
      if (ctx.state.data) {
        ctx.commit('setLoading', true)
        return
      }
      const resp = await getAbout()
      ctx.commit('setData', resp)
      ctx.commit('setLoading', true)
    }
  }
}
